<?php

declare (strict_types=1);

namespace App\Model;

use Hyperf\DbConnection\Model\Model;

/**
 * 回合
 * Class RoundsModel
 * @package App\Model
 */
class RoundsModel extends Model
{

    protected $table = 'rounds';

    protected $guarded = [
        'id',
        'created_at',
        'updated_at',
    ];

    protected $casts = [
        'win_uids' => 'array',
        'lost_uids' => 'array',

        'banker_cards' => 'array',
        'prev_cards' => 'array',
        'next_cards' => 'array',
        'opposite_cards' => 'array',

        'banker_ma' => 'array',
        'prev_ma' => 'array',
        'next_ma' => 'array',
        'opposite_ma' => 'array',
        'win_ma' => 'array',
        'lost_ma' => 'array',

        'lai_zi' => 'array',
        'remain_cards' => 'array',

        'banker_discard' => 'array',
        'prev_discard' => 'array',
        'next_discard' => 'array',
        'opposite_discard' => 'array',

        'banker_peng' => 'array',
        'prev_peng' => 'array',
        'next_peng' => 'array',
        'opposite_peng' => 'array',

        'banker_gang' => 'array',
        'prev_gang' => 'array',
        'next_gang' => 'array',
        'opposite_gang' => 'array',

        'has_zi_pai' => 'boolean',
        'shai_zi' => 'array',
    ];


    /**
     * 房间
     * @return \Hyperf\Database\Model\Relations\BelongsTo
     */
    public function Room()
    {
        return $this->belongsTo(RoomsModel::class, 'rooms_id');
    }

    /**
     * 回合动作
     * @return \Hyperf\Database\Model\Relations\HasMany
     */
    public function Action()
    {
        return $this->hasMany(RoundActionModel::class, 'rounds_id');
    }

    /**
     * 回合动作组
     * @return \Hyperf\Database\Model\Relations\HasMany
     */
    public function ActionGroup()
    {
        return $this->hasMany(RoundActionGroupModel::class, 'rounds_id');
    }
}